Skip to content

SNRC name resolver#1795

Open
brenzi wants to merge 10 commits into
masterfrom
ab/name-resolver
Open

SNRC name resolver#1795
brenzi wants to merge 10 commits into
masterfrom
ab/name-resolver

Conversation

@brenzi

@brenzi brenzi commented Jun 3, 2026

Copy link
Copy Markdown
Collaborator

Implements a REST API to resolve namespaces to simplex contact and channel plus additional metadata

@brenzi brenzi changed the base branch from stable to master June 3, 2026 08:49
shumvgolove added a commit that referenced this pull request Jun 6, 2026
Convergence on the Python resolver shape (PR #1795 `snrc-resolve.py`) so
a names router can be backed either by the direct-ETH-RPC resolver or by
the Python REST resolver without changing the wire format clients see.

Wire-level changes:

- Add `nickname`, `website`, `location`, `simplex.contact`,
  `simplex.channel`, `ETH`, `BTC`, `XMR`, `DOT`, `resolver` (SNRC
  contract address that produced the record); all but `name`, `owner`,
  `resolver` are optional.
- Drop `displayName` (now `name`), `channelLinks`, `contactLinks`,
  `adminAddress`, `adminEmail`, `expiry`, `isTest`.
- The wire NameRecord no longer carries `expiry`; clients trust the
  server's filter. Expiry checking moves into `decodeGetRecord`, which
  now takes a `nowSec :: Int64` argument (the placeholder remains, but
  the field-layout-aware decoder will apply the filter once it lands).
- Testnet status is derived from the queried TLD (`TLDTesting` vs
  `TLDSimplex`) rather than an in-record flag.

Other:

- ToJSON/FromJSON are hand-rolled because Aeson TH doesn't accommodate
  dot-keys (`simplex.contact`) or uppercase coin keys (`ETH`/`BTC`...).
- `NameLink` newtype is removed (no longer used internally); per-field
  byte caps are applied directly in the FromJSON parser.
- Update the canonical-encoding spec in protocol/simplex-messaging.md.
shumvgolove added a commit that referenced this pull request Jun 8, 2026
Replace the direct Ethereum JSON-RPC eth_call flow with HTTP calls to the
snrc-resolve.py REST resolver (PR #1795). The Python service owns the
on-chain registry mapping per TLD; the SMP server forwards each RSLV as
`GET /resolve/<name>` and parses the JSON response as a NameRecord.

Wire-format changes (no SMP version bump):

* RslvRequest.contract is now parsed but ignored server-side. The wire
  field is retained for forward compatibility with possible future
  eth-backed implementations. The agent sends a zero-address placeholder.
* NameRecord JSON keys match the Python resolver exactly: lowercase
  camelCase (simplexContact / simplexChannel) and lowercase coin keys
  (eth/btc/xmr/dot). Text fields use the empty string `""` as the unset
  sentinel; coin fields use JSON null.

Module changes:

* New: Simplex.Messaging.Server.Names.HttpResolver — http-client +
  redirect-disabled GET, body cap, optional Authorization header,
  scrubUrl extracted from the old eth/RPC module.
* Rewritten: Simplex.Messaging.Server.Names — HTTP backend with a
  ResolverCall test seam (replaces EthCall); ResolverCallKind tags
  fetch vs health probe so tests can assert routing. 404/400 map to
  NotFound; 5xx and transport failures map to ResolverError; decode
  errors to ResolverDecodeErr. parseName replaces verifyRslv (no more
  contract whitelist).
* Deleted: Simplex.Messaging.Server.Names.Eth.{RPC,SNRC} and
  Simplex.Messaging.SimplexName.Contracts — the ABI decoder, the
  Keccak namehash, and the TLD->contract whitelist are all owned by
  the Python resolver now.

Server-side flow:

* Server.hs's RSLV handler: parseName (instead of verifyRslv) + a
  single resolveName call (no contract argument).
* Env/STM.hs: pingEndpoint now hits `GET /health` (200 OK = ready).
* Main.hs INI keys renamed from `ethereum_endpoint` / `rpc_*` to
  `resolver_endpoint` / `resolver_*`. Dropped `rpc_max_concurrency`
  (http-client manages its own pool). Default
  `resolver_max_response_bytes` lowered to 65536 (the Python resolver's
  responses are ~2 KB; the previous 262144 was sized for ABI-encoded
  blobs). validateUrl SSRF hardening is preserved verbatim, only
  error messages and INI key names changed.

Agent side:

* resolveSimplexName' no longer consults `tldContract`; it passes a
  zero-address placeholder as RslvRequest.contract. The agent's public
  API is unchanged.

Spec doc updates:

* Backing store section: reference implementation forwards RSLV to the
  Python REST resolver; alternatives are valid as long as they expose
  the same HTTP shape or substitute a different transport.
* RslvRequest.contract documented as ignored / reserved.
* NameRecord field table updated: simplexContact (was simplex.contact),
  eth/btc/xmr/dot (was ETH/BTC/XMR/DOT), Text fields use empty string
  when unset (was nullable).

Tests:

* SMPNamesTests.hs: ABI decoder tests deleted; HTTP resolver tests
  added (success, 404, 400, 502, transport failure, malformed JSON,
  non-NameRecord JSON, health probe routing). 31 examples.
* RSLVTests.hs and AgentTests/ResolveNameTests.hs: switched from the
  eth-call stub to the resolver-call stub. The old INTERNAL "no
  resolver contract for TLD" branch is gone — TLDWeb now reaches the
  server and the resolver decides whether to honour it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants